﻿<link href="../../Content/themes/base/jquery.ui.all.css"
        rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $("#StartDate").datepicker();
        $("#EndDate").datepicker();
    });
</script>

@using vITs.Site.Models
@{
    ViewBag.Title = "Sök uppdrag";
}

<script type="text/javascript">
    var qs = new Querystring();
    var startdate = qs.get("StartDate");
    var enddate = qs.get("EndDate");
</script>

<fieldset>
    <legend>
        <h2>Uppdrag</h2>
    </legend>
    <br />
    @using (this.Html.BeginForm("AssignmentList", "Handler", FormMethod.Post)) {
    <fieldset>
    <legend>Sök:</legend> 
    <br />
    Startdatum: @Html.TextBox("StartDate")
    <br />
    Slutdatum: @Html.TextBox("EndDate")
    <br />
    <input type="submit" value="Sök" />
    </fieldset>
    }

    @if (ViewBag.StartDate != null)
    {
    <input type="button" value="Exportera till excel" onclick="javascript:window.location='@Url.Action("AssignmentListExcel", "Report", new { StartDate = @ViewBag.StartDate, EndDate = @ViewBag.EndDate })';" />
    }
    
    @if (ViewBag.Assignments != null)
    {
    foreach (var key in this.ViewBag.Assignments.Keys)
    {
        String status = ((vITs.Site.Models.DataModels.AssignmentStatus)key).GetDisplayName();
        
        <fieldset>
            <legend>@status</legend>
            <br />
            <ul>
            @foreach (var assignment in this.ViewBag.Assignments[key])
            {
                <li>
                    <a href="@this.Url.Action("ViewAssignment", "Handler", new { AssignmentId = @assignment.AssignmentId })">@assignment.AssignmentName</a> (@assignment.StartDate.ToString("yyyy-MM-dd") &mdash; @assignment.EndDate.ToString("yyyy-MM-dd"))
                </li>
            }
            </ul>
        </fieldset>
    }
    }
</fieldset>
